package cn.rengy.web.framework.role.service;

import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresRoles;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.rengy.lang.ResultEntity;


/**
 * 
 * 角色管理
 */
@Controller
@RequestMapping(value = "/authenticated/role")
public class RoleController {
	private static Logger logger = LoggerFactory.getLogger(RoleController.class);
	@Autowired
	private RoleService roleService;
	
	/**
	 * 查询授权数据
	 * @param param
	 * @return
	 */
	@RequestMapping(value="searchAuth",method = RequestMethod.POST)
	@ResponseBody
	@RequiresRoles(value={"developer"})
	public ResultEntity<Map<String,Object>> searchAuth(@RequestBody Map<String,Object> param){
		return ResultEntity.ok(roleService.searchAuth(param));
	}
	
	@RequestMapping(value="saveAuth",method = RequestMethod.POST)
	@ResponseBody
	@RequiresRoles(value={"developer"})
	public ResultEntity<?> saveAuth(@RequestBody Map<String,Object> param){
		roleService.saveAuth(param);
		return ResultEntity.ok();
	}
	
	@RequestMapping(value="delete",method = RequestMethod.POST)
	@ResponseBody
	@RequiresRoles(value={"developer"})
	public ResultEntity<?> delete(@RequestBody Map<String,Object> param){
		roleService.delete(param);
		return ResultEntity.ok();
	}
}
